#include "gskroundedrectprivate.h"
+typedef struct _GskVulkanPushConstantsWire GskVulkanPushConstantsWire;
+
+struct _GskVulkanPushConstantsWire
+{
+ struct {
+ float mvp[16];
+ float clip[12];
+ } common;
+};
+
void
gsk_vulkan_push_constants_init (GskVulkanPushConstants *constants,
const graphene_matrix_t *mvp,
gsk_vulkan_push_constants_wire_init (GskVulkanPushConstantsWire *wire,
const GskVulkanPushConstants *self)
{
- graphene_matrix_to_float (&self->mvp, wire->vertex.mvp);
- gsk_rounded_rect_to_float (&self->clip.rect, wire->vertex.clip);
+ graphene_matrix_to_float (&self->mvp, wire->common.mvp);
+ gsk_rounded_rect_to_float (&self->clip.rect, wire->common.clip);
}
void
-gsk_vulkan_push_constants_push_vertex (const GskVulkanPushConstants *self,
- VkCommandBuffer command_buffer,
- VkPipelineLayout pipeline_layout)
+gsk_vulkan_push_constants_push (const GskVulkanPushConstants *self,
+ VkCommandBuffer command_buffer,
+ VkPipelineLayout pipeline_layout)
{
GskVulkanPushConstantsWire wire;
vkCmdPushConstants (command_buffer,
pipeline_layout,
- VK_SHADER_STAGE_VERTEX_BIT,
- G_STRUCT_OFFSET (GskVulkanPushConstantsWire, vertex),
- sizeof (wire.vertex),
- &wire.vertex);
-}
-
-#if 0
-void
-gsk_vulkan_push_constants_push_fragment (GskVulkanPushConstants *self,
- VkCommandBuffer command_buffer,
- VkPipelineLayout pipeline_layout)
-{
- vkCmdPushConstants (command_buffer,
- pipeline_layout,
- VK_SHADER_STAGE_FRAGMENT_BIT,
- G_STRUCT_OFFSET (GskVulkanPushConstants, fragment),
- sizeof (self->fragment),
- &self->fragment);
+ VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
+ G_STRUCT_OFFSET (GskVulkanPushConstantsWire, common),
+ sizeof (wire.common),
+ &wire.common);
}
-#endif
uint32_t
gst_vulkan_push_constants_get_range_count (void)
{
static const VkPushConstantRange ranges[1] = {
{
- .stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
- .offset = G_STRUCT_OFFSET (GskVulkanPushConstantsWire, vertex),
- .size = sizeof (((GskVulkanPushConstantsWire *) 0)->vertex)
-#if 0
- },
- {
- .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
- .offset = G_STRUCT_OFFSET (GskVulkanPushConstants, fragment),
- .size = sizeof (((GskVulkanPushConstants *) 0)->fragment)
-#endif
+ .stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
+ .offset = G_STRUCT_OFFSET (GskVulkanPushConstantsWire, common),
+ .size = sizeof (((GskVulkanPushConstantsWire *) 0)->common)
}
};
G_BEGIN_DECLS
typedef struct _GskVulkanPushConstants GskVulkanPushConstants;
-typedef struct _GskVulkanPushConstantsWire GskVulkanPushConstantsWire;
struct _GskVulkanPushConstants
{
GskVulkanClip clip;
};
-struct _GskVulkanPushConstantsWire
-{
- struct {
- float mvp[16];
- float clip[12];
- } vertex;
-#if 0
- struct {
- } fragment;
-#endif
-};
-
const VkPushConstantRange *
gst_vulkan_push_constants_get_ranges (void) G_GNUC_PURE;
uint32_t gst_vulkan_push_constants_get_range_count (void) G_GNUC_PURE;
const GskVulkanPushConstants *src,
const GskRoundedRect *rect);
-void gsk_vulkan_push_constants_push_vertex (const GskVulkanPushConstants *self,
+void gsk_vulkan_push_constants_push (const GskVulkanPushConstants *self,
VkCommandBuffer command_buffer,
VkPipelineLayout pipeline_layout);
break;
case GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS:
- gsk_vulkan_push_constants_push_vertex (&op->constants.constants,
- command_buffer,
- gsk_vulkan_pipeline_layout_get_pipeline_layout (layout));
+ gsk_vulkan_push_constants_push (&op->constants.constants,
+ command_buffer,
+ gsk_vulkan_pipeline_layout_get_pipeline_layout (layout));
break;
default:
#version 420 core
+#include "constants.glsl"
+
struct RoundedRect {
vec4 bounds;
vec4 corners;
layout(location = 0) in vec2 inPos;
layout(location = 1) in vec2 inTexCoord;
-layout(location = 2) in flat vec4 inClipBounds;
-layout(location = 3) in flat vec4 inClipWidths;
layout(set = 0, binding = 0) uniform sampler2D inTexture;
void main()
{
- RoundedRect r = RoundedRect(vec4(inClipBounds.xy, inClipBounds.xy + inClipBounds.zw), inClipWidths);
+ RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw), push.clip_widths);
color = texture (inTexture, inTexCoord) * clip (inPos, r);
}
layout(location = 0) out vec2 outPos;
layout(location = 1) out vec2 outTexCoord;
-layout(location = 2) out flat vec4 outClipBounds;
-layout(location = 3) out flat vec4 outClipWidths;
out gl_PerVertex {
vec4 gl_Position;
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
- outClipBounds = push.clip_bounds;
- outClipWidths = push.clip_widths;
vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
rect.zw / inRect.zw);
#version 420 core
+#include "constants.glsl"
#include "rounded-rect.glsl"
layout(location = 0) in vec2 inPos;
layout(location = 3) in vec4 inCornerWidths;
layout(location = 4) in vec4 inCornerHeights;
layout(location = 5) in vec4 inBorderWidths;
-layout(location = 6) in flat vec4 inClipBounds;
-layout(location = 7) in flat vec4 inClipWidths;
-layout(location = 8) in flat vec4 inClipHeights;
layout(location = 0) out vec4 color;
vec4
clip (vec4 color)
{
- RoundedRect r = RoundedRect (vec4(inClipBounds.xy, inClipBounds.xy + inClipBounds.zw), inClipWidths, inClipHeights);
+ RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw), push.clip_widths, push.clip_heights);
return color * rounded_rect_coverage (r, inPos);
}
layout(location = 3) out flat vec4 outCornerWidths;
layout(location = 4) out flat vec4 outCornerHeights;
layout(location = 5) out flat vec4 outBorderWidths;
-layout(location = 6) out flat vec4 outClipBounds;
-layout(location = 7) out flat vec4 outClipWidths;
-layout(location = 8) out flat vec4 outClipHeights;
out gl_PerVertex {
vec4 gl_Position;
outCornerWidths = inCornerWidths;
outCornerHeights = inCornerHeights;
outBorderWidths = inBorderWidths;
- outClipBounds = push.clip_bounds;
- outClipWidths = push.clip_widths;
- outClipHeights = push.clip_heights;
}
#version 420 core
+#include "constants.glsl"
+
layout(location = 0) in vec2 inPos;
layout(location = 1) in vec4 inColor;
-layout(location = 2) in vec4 inClipBounds;
-layout(location = 3) in vec4 inClipWidths;
layout(location = 0) out vec4 color;
void main()
{
- RoundedRect r = RoundedRect(vec4(inClipBounds.xy, inClipBounds.xy + inClipBounds.zw), inClipWidths);
+ RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw), push.clip_widths);
- color = vec4(inColor.rgb * inColor.a, inColor.a) * clip (inPos, r);
+ color = vec4(inColor.rgb * inColor.a, inColor.a) * clip (inPos, r);
}
layout(location = 0) out vec2 outPos;
layout(location = 1) out flat vec4 outColor;
-layout(location = 2) out flat vec4 outClipBounds;
-layout(location = 3) out flat vec4 outClipWidths;
out gl_PerVertex {
vec4 gl_Position;
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
outColor = inColor;
- outClipBounds = push.clip_bounds;
- outClipWidths = push.clip_widths;
}
#version 420 core
+#include "constants.glsl"
+
struct RoundedRect {
vec4 bounds;
vec4 corners;
layout(location = 0) in vec2 inPos;
layout(location = 1) in vec2 inTexCoord;
-layout(location = 2) in flat vec4 inClipBounds;
-layout(location = 3) in flat vec4 inClipWidths;
-layout(location = 4) in flat mat4 inColorMatrix;
-layout(location = 8) in flat vec4 inColorOffset;
+layout(location = 2) in flat mat4 inColorMatrix;
+layout(location = 6) in flat vec4 inColorOffset;
layout(set = 0, binding = 0) uniform sampler2D inTexture;
void main()
{
- RoundedRect r = RoundedRect(vec4(inClipBounds.xy, inClipBounds.xy + inClipBounds.zw), inClipWidths);
+ RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw), push.clip_widths);
color = color_matrix (texture (inTexture, inTexCoord), inColorMatrix, inColorOffset) * clip (inPos, r);
}
layout(location = 0) out vec2 outPos;
layout(location = 1) out vec2 outTexCoord;
-layout(location = 2) out flat vec4 outClipBounds;
-layout(location = 3) out flat vec4 outClipWidths;
-layout(location = 4) out flat mat4 outColorMatrix;
-layout(location = 8) out flat vec4 outColorOffset;
+layout(location = 2) out flat mat4 outColorMatrix;
+layout(location = 6) out flat vec4 outColorOffset;
out gl_PerVertex {
vec4 gl_Position;
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
- outClipBounds = push.clip_bounds;
- outClipWidths = push.clip_widths;
vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
rect.zw / inRect.zw);
#version 420 core
+#include "constants.glsl"
+
struct ColorStop {
float offset;
vec4 color;
layout(location = 1) in float inGradientPos;
layout(location = 2) in flat int inRepeating;
layout(location = 3) in flat int inStopCount;
-layout(location = 4) in flat vec4 inClipBounds;
-layout(location = 5) in flat vec4 inClipWidths;
-layout(location = 6) in flat ColorStop inStops[8];
+layout(location = 4) in flat ColorStop inStops[8];
layout(location = 0) out vec4 outColor;
void main()
{
- RoundedRect r = RoundedRect(vec4(inClipBounds.xy, inClipBounds.xy + inClipBounds.zw), inClipWidths);
+ RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw), push.clip_widths);
float pos;
if (inRepeating != 0)
layout(location = 1) out float outGradientPos;
layout(location = 2) out flat int outRepeating;
layout(location = 3) out flat int outStopCount;
-layout(location = 4) out flat vec4 outClipBounds;
-layout(location = 5) out flat vec4 outClipWidths;
-layout(location = 6) out flat ColorStop outStops[8];
+layout(location = 4) out flat ColorStop outStops[8];
out gl_PerVertex {
vec4 gl_Position;
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
outGradientPos = get_gradient_pos (pos);
- outClipBounds = push.clip_bounds;
- outClipWidths = push.clip_widths;
outRepeating = inRepeating;
outStopCount = inStopCount;
outStops[0].offset = inOffsets0[0];